// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`destructuring.js 1`] = `
// @flow

let [x, y] = [1, 2];

/**
 * Test what happens when the destructuring is unevaluated. In this case,
 * \`this\` in a function is unbound, so we never actually find out the type of
 * \`this.returnsATuple()\` is; thus, we never evaluate \`b\` and so type-at-pos
 * returns EmptyT.
 */
export const X = {
  returnsATuple: function(): [number, number] {
    return [1, 2];
  },

  test: function() {
    let [a, b] = this.returnsATuple();
  }
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow

let [x, y] = [1, 2];

/**
 * Test what happens when the destructuring is unevaluated. In this case,
 * \`this\` in a function is unbound, so we never actually find out the type of
 * \`this.returnsATuple()\` is; thus, we never evaluate \`b\` and so type-at-pos
 * returns EmptyT.
 */
export const X = {
  returnsATuple: function(): [number, number] {
    return [1, 2];
  },

  test: function() {
    let [a, b] = this.returnsATuple();
  }
};

`;

exports[`function_expressions.js 1`] = `
// @flow

// TODO: type-at-pos between the ()'s should be () => void
// class X {
//   foo(): void {}
// }

const a = {
  bar(): void {}
};

const b = {
  bar: function (): void {}
};

const c = {
  m<T>(x: T): T { return x; }
};

const d = {
  m: function<T>(x: T): T { return x; }
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow

// TODO: type-at-pos between the ()'s should be () => void
// class X {
//   foo(): void {}
// }

const a = {
  bar(): void {}
};

const b = {
  bar: function(): void {}
};

const c = {
  m<T>(x: T): T {
    return x;
  }
};

const d = {
  m: function<T>(x: T): T {
    return x;
  }
};

`;

exports[`generics.js 1`] = `
// @flow

class C<X> { }
var cn: C<number> = new C;
cn;

function foo() { return C; }
var D = foo();
var dn: D<number> = new C;
dn;

type E<X> = C<X>;
var en: E<number> = new C;
en;

type F<X> = C<void>;
var fn: F<number> = new C;
fn;

type O<X> = { x: X };
var on: O<number> = { x: 0 };
on;

type Mono = C<void>;
var mn: Mono<number> = new C; // error: application of non-poly type
mn;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow

class C<X> {}
var cn: C<number> = new C();
cn;

function foo() {
  return C;
}
var D = foo();
var dn: D<number> = new C();
dn;

type E<X> = C<X>;
var en: E<number> = new C();
en;

type F<X> = C<void>;
var fn: F<number> = new C();
fn;

type O<X> = { x: X };
var on: O<number> = { x: 0 };
on;

type Mono = C<void>;
var mn: Mono<number> = new C(); // error: application of non-poly type
mn;

`;

exports[`import.js 1`] = `
// @flow
var num = 42;
function bar() { }
bar();
module.exports = num;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
var num = 42;
function bar() {}
bar();
module.exports = num;

`;

exports[`object_special_cases.js 1`] = `
/* @flow */

let tests = [
  function() {
    let x = {};
    Object.defineProperty(x, 'foo', { value: '' });
  },
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */

let tests = [
  function() {
    let x = {};
    Object.defineProperty(x, "foo", { value: "" });
  }
];

`;

exports[`optional.js 1`] = `
// @flow

function foo(x?: string) {
  return x;
}

foo();

function bar(obj: { x?: string }) {
  return obj.x;
}

function qux(x?) {
  return x;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow

function foo(x?: string) {
  return x;
}

foo();

function bar(obj: { x?: string }) {
  return obj.x;
}

function qux(x?) {
  return x;
}

`;

exports[`predicates.js 1`] = `
/* @flow */

let x = 0;
if (x == null) {}
if (x == undefined) {}
if (Array.isArray(x)) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */

let x = 0;
if (x == null) {
}
if (x == undefined) {
}
if (Array.isArray(x)) {
}

`;

exports[`react.js 1`] = `
import React from "react";
React.createElement;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import React from "react";
React.createElement;

`;

exports[`templates.js 1`] = `
/* @flow */
\`foo bar\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
\`foo bar\`;

`;

exports[`test.js 1`] = `
// @flow
var str = require('./import');
function foo() { }
foo();
str

type Point = [number, string];
const x:Point = [1, "foo"];
type MyStr = "cool";
const y:MyStr = "cool";
type MyBool = true;
const z:MyBool = true;
type MyNum = 42;
const w:MyNum = 42;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
var str = require("./import");
function foo() {}
foo();
str;

type Point = [number, string];
const x: Point = [1, "foo"];
type MyStr = "cool";
const y: MyStr = "cool";
type MyBool = true;
const z: MyBool = true;
type MyNum = 42;
const w: MyNum = 42;

`;

exports[`trycatch.js 1`] = `
// @flow

try {
  throw "foo";
} catch (e) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow

try {
  throw "foo";
} catch (e) {}

`;
